if __name__ == '__main__':
    from enetity_extraction.company_data_test import get_data
    from enetity_extraction.Information_Extraction import extract_information
    from enetity_extraction.test_docx import get_docx_extraction_result

    # 功能测试
    test_data = get_data()
    from logic_rule.serial_number_check import is_valid_serial_number
    from logic_rule.trial_date_check import chinese_date_to_datetime
    from logic_rule.court_code_check import is_valid_court_code, create_global_set
    from logic_rule.signature_check import check_signature
    from logic_rule.case_code_check import check_case_code, create_type_codes
    from logic_rule.money_check import check_money

    # doc_file_path = "F:\code\pytorch\judicial_document_proofreading\enetity_extraction/0815改错不报文书/1-周某某与胡某财产损害赔偿纠纷二审民事案169606514.docx"
    doc_file_path = r"F:\code\pytorch\judicial_document_proofreading\enetity_extraction\0815改错不报文书\16-六盘水某某房地产开发有限公司与六盘某某资产管理有限责任公司、...纷首次执行案170964596.docx"
    # doc_file_path = r"F:\code\pytorch\judicial_document_proofreading\enetity_extraction\0815改错不报文书\3-潘某某与盘水市水城区发耳镇人民政府强制拆除房屋或者设施、强制拆除房屋或者设施二审行政案169777511.docx"

    # doc案号
    court_codes = create_global_set()
    sentences_extract = get_docx_extraction_result(doc_file_path)[1]
    type_codes = create_type_codes()
    result = check_case_code(court_codes, type_codes, sentences_extract)

    # doc金额
    # sentences_extract = get_docx_extraction_result(doc_file_path)[1]
    # result = check_money(sentences_extract)

    # doc审判时间
    # doc_file_path = "F:\code\pytorch\judicial_document_proofreading\enetity_extraction/0815改错不报文书/1-周某某与胡某财产损害赔偿纠纷二审民事案169606514.docx"
    # doc_file_path = r"F:\code\pytorch\judicial_document_proofreading\enetity_extraction\0815改错不报文书\2-贵州某某集团有限公司与六盘水名某某房地产开发有限公司建设工程合同纠纷执行异议案170291123.docx"
    # sentences_extract = get_docx_extraction_result(doc_file_path)[1]
    # result = chinese_date_to_datetime(sentences_extract)

    # 正文序号
    # sentences_extract = get_docx_extraction_result(doc_file_path)[1]
    # result = is_valid_serial_number(sentences_extract)

    # 正文序号
    sentences_extract = extract_information([test_data[53]["错误用例"]])
    result = is_valid_serial_number(sentences_extract)

    sentences_extract = extract_information([test_data[53]["正确句子"]])
    result = is_valid_serial_number(sentences_extract)

    # 审判日期
    sentences_extract = extract_information([test_data[49]["错误用例"]])
    result = chinese_date_to_datetime(sentences_extract)

    sentences_extract = extract_information([test_data[49]["正确句子"]])
    result = chinese_date_to_datetime(sentences_extract)

    # 法院代字
    sentences_extract = extract_information([test_data[54]["错误用例"]])
    court_codes = create_global_set()
    result = is_valid_court_code(court_codes, sentences_extract)

    sentences_extract = extract_information([test_data[54]["正确句子"]])
    court_codes = create_global_set()
    result = is_valid_court_code(court_codes, sentences_extract)

    # 尾部落款
    sentences_extract = extract_information([test_data[47]["错误用例"]])
    result = check_signature(sentences_extract)

    sentences_extract = extract_information([test_data[47]["正确句子"]])
    result = check_signature(sentences_extract)

    # 案号
    sentences_extract = extract_information([test_data[48]["错误用例"]])
    type_codes = create_type_codes()
    result = check_case_code(court_codes, type_codes, sentences_extract)

    sentences_extract = extract_information([test_data[48]["正确句子"]])
    type_codes = create_type_codes()
    result = check_case_code(court_codes, type_codes, sentences_extract)

    # 金额前面不应该加人民币
    sentences_extract = extract_information([test_data[52]["错误用例"]])
    result = check_money(sentences_extract)

    sentences_extract = extract_information([test_data[52]["正确句子"]])
    result = check_money(sentences_extract)

    pass
